/*
 * @Author: your name
 * @Date: 2021-05-06 09:53:34
 * @LastEditTime: 2021-05-06 16:28:33
 * @LastEditors: Please set LastEditors
 * @Description: 分享js
 * @FilePath: /medicine-web/src/utils/share.js
 */
import QRCode from 'qrcodejs2'
import Vue from 'vue'
const share = {
  iframe_width: 600,
  iframe_height: 750,
  iframe_top: window.innerHeight / 2 - 750 / 2,
  iframe_left: window.innerWidth / 2 - 600 / 2,
  qrcode: null,
  qq_zone_url: 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey',
  toShareQQZone: function (url, title, desc, summary) { // 连接地址， 标题，  描述， 总结
    window.open(`${this.qq_zone_url}?url=${url}&title=${title}&desc=${desc}&summary=${summary}`,'',`top=${this.iframe_top}, left=${this.iframe_left}, width=${this.iframe_width}, height=${this.iframe_height},location=no, menubar=no, status=no, toolbar=no` );
  },
  xin_lang_url: 'http://service.weibo.com/share/share.php',
  xin_lang_code: 'utf-8',
  toShareXinLang: function (url, title) { // 连接地址, 标题
    window.open(`${this.xin_lang_url}?url=${url}&title=${title}&code=${this.xin_lang_code}`,'',`top=${this.iframe_top}, left=${this.iframe_left}, width=${this.iframe_width}, height=${this.iframe_height},location=no, menubar=no, status=no, toolbar=no` );
  },
  toShareWeChat: function (url) {
    Vue.prototype.$nextTick(() => {
      if (this.qrcode) {
        this.qrcode.clear()
      }
      this.qrcode = new QRCode(document.getElementById('wechat-qr-code'), {
        text: url,
        width: 200,
        height: 200,
      })
    })
  }
}
export default share